//
//  Loan_OrderAffirmViewController.m
//  JinFuThree
//
//  Created by 爱尚 on 2018/9/19.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "Loan_OrderAffirmViewController.h"
#import "Loan_RightImageView.h"
#import "Loan_OrderSubmitViewController.h"
#import "Mediator+My.h"

@interface Loan_OrderAffirmViewController ()
@property(nonatomic,strong)UIScrollView *myScrollView;


@property(nonatomic,strong)Loan_RightImageView *loanMoney;//借款金额
@property(nonatomic,strong)Loan_RightImageView *InstallmentPeriods;//分期期数
@property(nonatomic,strong)Loan_RightImageView *repaymentWay;//还款方式
@property(nonatomic,strong)Loan_RightImageView *loanPurpose;//借款用途
@property(nonatomic,strong)Loan_RightImageView *collectionAccount;//收款账户
@property(nonatomic,strong)Loan_RightImageView *shouldPay;//每期应还


@property(nonatomic,strong)UILabel *firstPeriodLabel;
@property(nonatomic,strong)UIButton *sureBtn;//确认借款
@property(nonatomic,strong)UIButton *cancelBtn;
@end

@implementation Loan_OrderAffirmViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"订单确认";
    [self initViews];
}

-(void)initViews{
    
    UIView *contentView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidthMao, 700)];
    contentView.backgroundColor = [UIColor whiteColor];
    
    [contentView addSubview:self.loanMoney];
    [self.loanMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(contentView.mas_left).offset(25);
        make.width.mas_offset(@(ScreenWidthMao-50));
        make.top.mas_equalTo(contentView.mas_top);
        make.height.mas_offset(@56);
    }];
//    [self.loanMoney.writeTextField mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.centerY.height.mas_equalTo(self.loanMoney.titleLabel);
//        make.right.mas_equalTo(self.loanMoney.mas_right).offset(0);
//        make.left.mas_equalTo(self.loanMoney.titleLabel.mas_right);
//    }];
//
    [self.loanMoney.writeTextField mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.height.mas_equalTo(self.loanMoney.titleLabel);
        make.right.mas_equalTo(self.loanMoney.mas_right).offset(0);
        make.left.mas_equalTo(self.loanMoney.titleLabel.mas_right);
    }];
    
    [contentView addSubview:self.InstallmentPeriods];
    [self.InstallmentPeriods mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(contentView.mas_left).offset(25);
        make.width.mas_offset(@(ScreenWidthMao-50));
        make.top.mas_equalTo(self.loanMoney.mas_bottom);
        make.height.mas_offset(@56);
    }];
    [self.InstallmentPeriods.writeTextField mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.height.mas_equalTo(self.InstallmentPeriods.titleLabel);
        make.right.mas_equalTo(self.InstallmentPeriods.mas_right).offset(0);
        make.left.mas_equalTo(self.InstallmentPeriods.titleLabel.mas_right);
    }];
    [contentView addSubview:self.repaymentWay];
    [self.repaymentWay mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.InstallmentPeriods);
        make.top.mas_equalTo(self.InstallmentPeriods.mas_bottom);
    }];
    
    [self.repaymentWay.writeTextField mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.height.mas_equalTo(self.repaymentWay.titleLabel);
        make.right.mas_equalTo(self.repaymentWay.mas_right).offset(0);
        make.left.mas_equalTo(self.repaymentWay.titleLabel.mas_right);
    }];
    [contentView addSubview:self.loanPurpose];
    [self.loanPurpose mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.InstallmentPeriods);
        make.top.mas_equalTo(self.repaymentWay.mas_bottom);
    }];
    [self.loanPurpose.writeTextField mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.height.mas_equalTo(self.loanPurpose.titleLabel);
        make.right.mas_equalTo(self.loanPurpose.mas_right).offset(0);
        make.left.mas_equalTo(self.loanPurpose.titleLabel.mas_right);
    }];
    [contentView addSubview:self.collectionAccount];
    [self.collectionAccount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.InstallmentPeriods);
        make.top.mas_equalTo(self.loanPurpose.mas_bottom);
    }];
    [self.collectionAccount.writeTextField mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.height.mas_equalTo(self.collectionAccount.titleLabel);
        make.right.mas_equalTo(self.collectionAccount.mas_right).offset(0);
        make.left.mas_equalTo(self.collectionAccount.titleLabel.mas_right);
    }];
    
    
   
    
    
    
    
    
    [contentView addSubview:self.shouldPay];
    
    
    [self.shouldPay mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(self.collectionAccount);
        make.top.mas_equalTo(self.collectionAccount.mas_bottom);
    }];
    
    [self.shouldPay.writeTextField mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.height.mas_equalTo(self.shouldPay.titleLabel);
        make.right.mas_equalTo(self.shouldPay.mas_right).offset(0);
        make.left.mas_equalTo(self.shouldPay.titleLabel.mas_right);
    }];
    
    
   
    
   
    
    
    
    self.myScrollView = [[UIScrollView alloc]initWithFrame:CGRectZero];
    self.myScrollView.contentSize = contentView.frame.size;
    self.myScrollView.showsVerticalScrollIndicator = NO;
    self.myScrollView.backgroundColor = RGBCOLOR(242, 242, 242, 1);
    [self.myScrollView addSubview:contentView];
    [self.view addSubview:self.myScrollView];
    [self.myScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).offset(0);
        make.bottom.mas_equalTo(self.view).offset(0);
    }];
    
    
    _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [_cancelBtn setTitleColor:ThemeMaoColor forState:UIControlStateNormal];
    _cancelBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    _cancelBtn.layer.masksToBounds = YES;
    _cancelBtn.layer.cornerRadius = 4;
    _cancelBtn.layer.borderColor = ThemeMaoColor.CGColor;
    _cancelBtn.layer.borderWidth = 1;
    [_cancelBtn addTarget:self action:@selector(cancelBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [contentView addSubview:_cancelBtn];
    [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(contentView.mas_left).offset(25);
        make.top.mas_equalTo(self.shouldPay.mas_bottom).offset(35);
        make.width.mas_offset(@((ScreenWidthMao-50-5)/2));
        make.height.mas_offset(@44);
        
    }];
    
    _sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_sureBtn setTitle:@"确定" forState:UIControlStateNormal];
    [_sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_sureBtn setBackgroundImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
    [_sureBtn setBackgroundColor:ThemeMaoColor];
    _sureBtn.layer.masksToBounds = YES;
    _sureBtn.layer.cornerRadius = 4;
    _sureBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [_sureBtn addTarget:self action:@selector(sureBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [contentView addSubview:_sureBtn];
    [self.sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.cancelBtn.mas_right).offset(5);
        make.centerY.height.width.mas_equalTo(self.cancelBtn);
    }];
    
    
}

-(void)sureBtnAction{
    
    Loan_OrderSubmitViewController *submitVC = [[Loan_OrderSubmitViewController alloc]init];
  
    submitVC.view.backgroundColor = [UIColor whiteColor];
    
    [submitVC updateUIWith:YES];
    [self.navigationController pushViewController:submitVC animated:YES];
}
-(void)cancelBtnAction{
//    Loan_OrderSubmitViewController *submitVC = [[Loan_OrderSubmitViewController alloc]init];
//    submitVC.view.backgroundColor = [UIColor whiteColor];
//
//    [submitVC updateUIWith:NO];
//
//    [self.navigationController pushViewController:submitVC animated:YES];
    
    [self.navigationController popToRootViewControllerAnimated:YES];
    
}

-(Loan_RightImageView *)loanMoney{
    if (!_loanMoney) {
        _loanMoney = [[Loan_RightImageView alloc]init];
        _loanMoney.titleLabel.text = @"借款金额";
        _loanMoney.writeTextField.text = @"1000元";
        _loanMoney.rightImageView.hidden = YES;
    }
    return _loanMoney;
}

-(Loan_RightImageView *)InstallmentPeriods{
    if (!_InstallmentPeriods) {
        _InstallmentPeriods = [[Loan_RightImageView alloc]init];
        _InstallmentPeriods.titleLabel.text = @"分期期数";
        _InstallmentPeriods.writeTextField.text = @"6个月";
        _InstallmentPeriods.rightImageView.hidden = YES;

    }
    return _InstallmentPeriods;
}

-(Loan_RightImageView *)repaymentWay{
    if (!_repaymentWay) {
        _repaymentWay = [[Loan_RightImageView alloc]init];
        _repaymentWay.titleLabel.text = @"分期方式";
        _repaymentWay.writeTextField.text = @"等额本息";
        _repaymentWay.rightImageView.hidden = YES;
        
    }
    return _repaymentWay;
}

-(Loan_RightImageView *)loanPurpose{
    if (!_loanPurpose) {
        _loanPurpose = [[Loan_RightImageView alloc]init];
        _loanPurpose.titleLabel.text = @"借款用途";
        _loanPurpose.writeTextField.text = @"3C产品";
        _loanPurpose.rightImageView.hidden = YES;
        
    }
    return _loanPurpose;
}

-(Loan_RightImageView *)collectionAccount{
    if (!_collectionAccount) {
        _collectionAccount = [[Loan_RightImageView alloc]init];
        _collectionAccount.titleLabel.text = @"收款账户";
        _collectionAccount.rightImageView.hidden = YES;
        _collectionAccount.writeTextField.text = @"招商银行储蓄卡";
    }
    return _collectionAccount;
    
}

-(Loan_RightImageView *)shouldPay{
    if (!_shouldPay) {
        _shouldPay = [[Loan_RightImageView alloc]init];
        _shouldPay.titleLabel.text = @"每期应还";
        _shouldPay.writeTextField.text = @"¥416.66";
        _shouldPay.rightImageView.hidden = YES;

    }
    return _shouldPay;

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
